package cn.cloud.butler.scheduled.repository;

import cn.cloud.butler.scheduled.domain.StateTimeSumHistoryEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

public interface StateTimeSumHistoryRepository extends JpaRepository<StateTimeSumHistoryEntity,Long> {


    @Query(value = "select * from StateTimeHistory where MacSN = ?1 and  DayTime = ?2",nativeQuery = true)
    StateTimeSumHistoryEntity findByMacSN(String macSN, String date);

    @Query(value = "update StateTimeHistory set DayTime = ?8 and Free = ?2,Running = ?4,OutLine = ?3,Warnning = ?5," +
            "TotalTime = ?6,StateTimes = ?7 where MacSN = ?1",nativeQuery = true)
    void updateByMacSN(String macsn, String free, String outLine, String running, String alarm, String total, String suntime, Date date);

    @Query(value = "update StateTimeHistory set Count = ?2 a",nativeQuery = true)
    void updateByMacSNs(Long id, Integer count, String date);

}
